home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
filed39a.zip
/
src
/
notes.os2
< prev
next >
Wrap
Text File
|
1993-04-11
|
19KB
|
579 lines
This file, NOTES.OS2, contains various messages and remarks on the OS/2 port,
and some magicfile suggestions by John Adams and Gisbert W. Selke. The email
messages have been edited slightly for brevity and clarity.
General notes:
1. Versions were compiled with Microsoft C 6.00A and EMX/gcc 0.8f.
2. Some of the original code assumed 32-bit integers. The magic structure
was changed in order to reduce the memory requirement. EMX and MSC changes
can be found by searching for OS2, EMX, and MSC. Bugs in the original
sources can be found by searching for the word "bugfix".
3. MSC stat() is broken on directory names--see Stat() in fsmagic.c.
MSC utime() works as documented, but is still broken.
4. Use spawn instead of fork in EMX/gcc. No pipes in MSDOS; use tempfil.
5. Add apptype.c, which uses DosQ[uery]AppType to determine the type
of executable. If apptype.c has the filename, then apptype can determine
the file type (see apptype.c for one special bug).
However, when the program is reading from stdin (or from a pipe due to "-z"
unwinding), then apptype only sees the part of the file provided by the
program (HOWMANY bytes). In this case, DosQ[uery]AppType may not be able to
distinguish, for example, a DOS exe from an OS/2 exe.
6. The usual problems with binary vs text files, EOL, and directory
separators must be handled. strtol in EMX and MSC libs returns LONG_MAX
on overflow--use strtoul with sign check or the supplied localsrc/strtol.c
=============================================================================
To: Darrel R Hankerson <hankedr@mail.auburn.edu>
Cc: darwin@cs.toronto.edu
Subject: Re: file ported to OS/2 1.x--2.x
In-Reply-To: Your message of Mon, 05 Apr 93 07:39:25 -0500.
Date: Mon, 5 Apr 1993 10:51:49 -0400
From: ian@sq.com
On Mon, 5 Apr 1993 07:39:25 -0400 Darrel R Hankerson wrote:
>I have nearly finished a port of [file v3 patchlevel5]
>for OS/2 1.x--2.x.
Glad to see it's been made available for OS/2. Thanks!
>The main changes are:
> 1. Change fork() to spawn() (needed for 1.x).
> 2. Add API calls to determine executable type.
> 3. malloc() the magic->desc to reduce memory usage (needed for 1.x).
Yes, I'd like to get the source changes back. HOWEVER time has not
stood still; I am now distributing version 3.9, and would rather not
have version 3.[5] circulating. If you have your diffs as patch files,
would it be possible for you to get the lastest (by ftp from
ftp.cs.toronto.edu in /pub/darwin/file), apply and test them again, and
then send the new version both to me (for baseline source) and also:
>... upload this as "file3[9].zip" (with context diff's and suitable
>documentation) to the main OS/2 sites...
Then we'd all be distributing the same version...
[The current version given in] patchlevel.h now says:
#define FILE_VERSION_MAJOR 3
#define patchlevel 9
Actually, when I get your OS/2 changes in, it'll be 3.10!
You also mentioned some
>Minor magic-file problems:
which I'll track down.
>The porting was made easier by the excellent form of the sources. Your
>program is a fine piece of work.
Thanks for the feedback!
Ian Darwin Free Fine File(1) FTPable From Ftp.cs.toronto.edu
ian@sq.com cd /pub/darwin/file; get README.FTP -; binary;
Toronto, Canada mget dist.*
=============================================================================
Date: Tue, 6 Apr 93 09:20:50 CDT
From: Darrel R Hankerson <hankedr>
To: ian@sq.com
Cc: darwin@cs.toronto.edu
In-Reply-To: ian@sq.com's message of Mon, 5 Apr 1993 10:51:49 -0400 <m0nfsWp-0003bFC@sq.com>
Subject: file ported to OS/2 1.x--2.x
[...] I do see a few new buglets in 3.9:
1. In ascmagic.c, you've changed the check for the esc. But there are only
nbytes of valid data, right?
#ifdef OS2 /* bugfix, not OS/2 specific */
s = (unsigned char*) memcpy(nbuf, buf, nbytes);
has_escapes = (memchr(s, '\033', nbytes) != NULL);
#else
s = (unsigned char*) memcpy(nbuf, buf, HOWMANY);
has_escapes = (memchr(s, '\033', HOWMANY) != NULL);
#endif
This reminds me of another question: In compress.c, would it make more
sense to always read HOMANY bytes from the pipe (as uncompress will give back
more bytes than the orig buffer)?
2. print.c has not been updated to include the additional typ's:
#ifdef OS2 /* bugfix, not OS/2 specific */
(m->type >= 0 && m->type < sizeof(typ) ?
#else
(m->type >= 0 && m->type < 7 ?
#endif
You will see the bug if you try "file -c"
I have working 32-bit OS/2, 16-bit OS/2, and MSDOS versions. I've
added the API calls (in OS/2 versions) to determine the executable
type (can't do this with magic entries).
Notes:
1. OS/2 1.x can't fork()--added code to use pipes and spawn.
2. OS/2 2.x doesn't really like to fork; do spawn.
3. MSDOS can't pipe; added tmpnam code.
4. The 16-bit versions require some changes:
(a) a few int's need to be unsigned
(b) a few "%d" in printf need to be "%ld"
(c) change magic->desc to a pointer and malloc as needed. We need the
room. More changes here are probably desired, as the current magic
file has over 900 valid entries and MAXMAGIS=1000 is near the max for
the 16-bit version. I did have some problems changing
mag->value.s to pointer when I played with 3.5. This would give more
room, but I have not modified 3.9 in this area.
5. OS/2 and MSDOS programs need to handle the "traditional" EOL "\r\n" in
addition to "\n". A minor change to softmagic.c (in 2 places) is needed.
As an example,
#ifdef OS2 /* handle both "\r\n" and "\n" */
(void) printf_eol(m->desc, p->s);
#else
if ((rt=strchr(p->s, '\n')) != NULL)
*rt = '\0';
(void) printf(m->desc, p->s);
if (rt)
*rt = '\n';
#endif
printf_eol is suitably defined. Without this change, the printout will
be incorrect for the tst files c.misc*.
6. OS/2 and MSDOS programs need to handle both '/' and '\\' as directory
separators. Some minor changes are required. MSC stat() is partially broken
on dir names, minor change added.
--Darrel Hankerson hankedr@mail.auburn.edu or hank@ducvax.auburn.edu
=============================================================================
Date: Sat, 27 Mar 93 22:36:16 CST
From: Darrel R Hankerson <hankedr>
To: mattes@iema.e-technik.uni-stuttgart.de
Subject: How to recognise 16-bit apps
DH said:
>> Proposal: Maybe we need a working "file" program with a flexible approach
>> to magic entries. Mattes' apptype could be part of this project.
EM said:
> I can provide the code required for identifying the emx version (and
> whether a program is an emx program or isn't), if you need it. A
> "file"-like approach cannot be used for identifying the type of an
> .exe file -- the NE and LX headers can be almost anywhere.
I would like to add the code you mention. I also plan to add the "apptype"
code.
1. Do you have any suggestions on the way the output should look?
2. How can I identify EMX .o and .obj files?
3. Where can I get an extensive list of magic entries?
--Darrel Hankerson hankedr@mail.auburn.edu or hank@ducvax.auburn.edu
=============================================================================
From: Eberhard Mattes <mattes@azu.informatik.uni-stuttgart.de>
Date: Fri, 2 Apr 93 14:03:24 +0200
To: hankedr@mail.auburn.edu
In-Reply-To: Darrel R Hankerson's message of Sat, 27 Mar 93 22:36:16 CST <9303280436.AA04246@ducserv>
Subject: How to recognise 16-bit apps
> 1. Do you have any suggestions on the way the output should look?
It should be `machine readable'.
> 2. How can I identify EMX .o and .obj files?
Use the standard i386 Unix magic entry for .o files (0407). .obj
files start with a THEADR record (a byte of 0x80, followed by two
bytes indicating the length of the record).
> 3. Where can I get an extensive list of mag